//
//  CarTableViewCell.m
//  CarFace
//
//  Created by dlios on 15-3-27.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "CarTableViewCell.h"

@implementation CarTableViewCell
- (void)dealloc
{
    [_logo release];
    [_carName release];
    [_car release];
    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.logo = [[UIImageView alloc]init];
        [self.contentView addSubview:self.logo];
        [_logo release];
        
        self.carName = [[UILabel alloc]init];
        self.carName.font = [UIFont systemFontOfSize:16.0f];
        [self.contentView addSubview:self.carName];
        [_carName release];
        
    }

    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat width = self.contentView.bounds.size.width;
    CGFloat height = self.contentView.bounds.size.height;
    
    self.logo.frame = CGRectMake(5, 5, width/6, height - 10);
    self.carName.frame = CGRectMake(width / 6 + 5 + 10, 5, width - width / 6 - 5 - 10, height - 10);
    
    self.carName.text = self.car.brandname;
     NSString *str = self.car.brandimg;
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
    [self.logo setImageWithURL:url];


}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
